<?php


namespace app\SuperAdmin\controller;
use think\Db;
use think\Controller;
use think\Session;
class OrderController extends Controller
{
    public function _initialize()
    {
        if (!Session::has('adminid'))
        {
            $this->redirect('index/index/index');
        }
    }

    public function index()
    {
       // 查询状态为1的用户数据 并且每页显示5条数据
         $list = Db::name('enroll')
         ->join('users','users.uid=enroll.uid')
         ->join('exercises','exercises.exerid=enroll.exerid')
         ->paginate(5);
          $u=Db::name('users')
            ->select();
        $e=Db::name('exercises')
            ->select();
        // 把分页数据赋值给模板变量list
       $this->assign('list', $list);
       $this->assign('users', $u);
       $this->assign('exercises', $e);
        // 渲染模板输出
          return $this->fetch('orders');
        
    }
    public  function delete($eid){
        
       if( db("enroll")->delete($eid)){
              $this->success("取消成功");
       }else{
           $this->error("取消失败");
       }

    }
   
}